package model.path;

import java.util.Date;

import utils.Point3D;

import model.MainModel;
import model.RoomModel;

public class Point4D extends Point3D
{
	private Date time;
	private RoomModel room;
	
	public Point4D(Point3D position)
	{
		super();
		super.copy(position);
		this.setTime(new Date());
	}
	
	public Point4D(Point3D position, Date time)
	{
		super();
		super.copy(position);
		this.setTime(time);
	}
	
	public Point4D(Point3D position, RoomModel room, Date time)
	{
		super();
		super.copy(position);
		this.setTime(time);
		this.setRoom(room);
	}
	
	public void setRoom(RoomModel room) {
		// TODO Auto-generated method stub
		this.room = room;
	}

	public Date getTime()
	{
		return this.time;			
	}
	
	public void setTime(Date date)
	{
		this.time = date;
	}
	
	public RoomModel getRoom()
	{
		return this.room;
	}

	public String toCSV() {
		String str = "";

		str += this.room.getID() + ";";
		str += this.x() + ";";
		str += this.y() + ";";
		str += this.time.getTime()+ ";";
		
		return str;
	}	
	
	public Point4D(MainModel model, String roomId, String x, String y, String time)
	{
		super();
		RoomModel roomModel = model.getRoomById(Integer.parseInt(roomId));
		float xValue = Float.parseFloat(x);
		float yValue = Float.parseFloat(y);
		Point3D position = new Point3D(xValue, yValue, 0);
		long timeValue = Long.parseLong(time);
		
		super.copy(position);
		
		this.setTime(new Date(timeValue));
		this.setRoom(roomModel);
	}
	
	public String toString()
	{
		return this.toCSV();
	}
}
